<template>
    <a-card :bordered="false">
        <LTable
            ref="todoTaskList"
            size="middle"
            rowKey="id"
            :formAttributes="formAttributes"
            :columns="columns"
            axiosUrl="/todoTask/list"
            :showPagination="true"
            
            :showQueryForm="true">

            <span slot="action" slot-scope="text, record">
                <a @click="handleTask(record)">查看任务</a>
            </span>
        </LTable>

        <todo-task-form ref="todoTaskForm" @close="refresh('todoTaskList')"></todo-task-form>
    </a-card>
</template>

<script>
import LTable from '@/components/lt/LTable' 
import request from '@/utils/flowRequest'
import {SysMixin} from '@/mixins/SysMixin'
import todoTaskForm from './todoTaskForm';

export default {
    name:'todoTaskList',
    components:{
       LTable, todoTaskForm
    },
    mixins:[SysMixin],
    data() {
        return {
            request,
            formAttributes: [
                {field:'templateName',label:'流程模板',component:'input',condition:'like'},
                {field:'id',label:'任务ID',component:'input',condition:'like'},
                {field:'assignee',label:'处理人编号',component:'input',condition:'like'}
            ],
            columns: [
                {
                    title: '#',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
                // {
                //     title: '流程ID',
                //     width: 150,
                //     ellipsis: true,
                //     dataIndex: 'procInstId'
                // },
                // {
                //     title: '任务ID',
                //     width: 150,
                //     ellipsis: true,
                //     dataIndex: 'id'
                // },
                {
                    title: '系统编号',
                    dataIndex: 'systemNo'
                },
                {
                    title: '流程模板',
                    dataIndex: 'templateName'
                },
                {
                    title: '环节名称',
                    dataIndex: 'name'
                },
                {
                    title: '处理人编号',
                    dataIndex: 'assignee'
                    
                },
                {
                    title: '任务开始时间',
                    dataIndex: 'createTime'
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    width: 100,
                    scopedSlots: { customRender: 'action' }
                }
            ]
        }
    },
    methods: {
        handleTask(record) {
            if (record.formPath) {
                let s = JSON.stringify(record)
                let newObj = JSON.parse(s)
                this.$refs['todoTaskForm'].open(newObj)
            } else {
                this.$message.success("流程模板未绑定form组件");
            }
        }
    }
}
</script>
